package com.wpam.scrabble.mobile;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.preference.PreferenceManager;

public class GameResources {

	private static GameResources instance_ = null;
	private Context context_;
	
	private Bitmap field_;
	private Bitmap letter2_;
	private Bitmap letter3_;
	private Bitmap word2_;
	private Bitmap word3_;
	private Bitmap blank_;
	
	private GameResources(Context ctx) {
		
		this.context_ = ctx;
		this.field_ = BitmapFactory.decodeResource(context_.getResources(), R.drawable.field);
		this.letter2_ = BitmapFactory.decodeResource(context_.getResources(), R.drawable.letter2);
		this.letter3_ = BitmapFactory.decodeResource(context_.getResources(), R.drawable.letter3);
		this.word2_ = BitmapFactory.decodeResource(context_.getResources(), R.drawable.word2);
		this.word3_ = BitmapFactory.decodeResource(context_.getResources(), R.drawable.word3);
		this.blank_ = BitmapFactory.decodeResource(context_.getResources(), R.drawable.blank);
	}
	
	public Context getContext() {
		return context_;
	}

	public static GameResources getInstance(Context ctx) {
		
		if (instance_ == null)
			instance_ = new GameResources(ctx);
		return instance_;
	}
	
	public static GameResources getInstance() {
		
		return instance_;
	}

	public Resources getResources() {
		return context_.getResources();
	}

	public Bitmap getField() {
		return field_;
	}

	public Bitmap getLetter2() {
		return letter2_;
	}

	public Bitmap getLetter3() {
		return letter3_;
	}

	public Bitmap getWord2() {
		return word2_;
	}

	public Bitmap getWord3() {
		return word3_;
	}

	public Bitmap getBlank() {
		return blank_;
	}
	
	public String getStringPreference(String name) {
		return PreferenceManager.getDefaultSharedPreferences(getContext().getApplicationContext()).getString(name, "");
	}
	
	public boolean getBooleanPreference(String name, boolean defaultVal) {
		return PreferenceManager.getDefaultSharedPreferences(context_).getBoolean(name, defaultVal);
	}
}
